#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "log4xecho.h"
using namespace log4x;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow, public ilog4x_listener
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    virtual void       echo(const string& line, int level, const vector<log4x_hl_t>& hlsearch);

protected:
    void               init();
    void               filter();
    void               checkBox(bool checked, int level);
    void               restart();

signals:
    void sgLogEchoLine(const QString &line, const int& level);

private slots:
    void on_log_echo(const QString &line, const int& level);

    void on_pushButton_selectFile_clicked();

    void on_pushButton_selectDir_clicked();

    void on_pushButton_start_clicked();

    void on_pushButton_reset_clicked();

    void on_radioButton_all_clicked(bool checked);

    void on_checkBox_trace_clicked(bool checked);

    void on_checkBox_debug_clicked(bool checked);

    void on_checkBox_info_clicked(bool checked);

    void on_checkBox_warn_clicked(bool checked);

    void on_checkBox_error_clicked(bool checked);

    void on_checkBox_fatal_clicked(bool checked);

    void on_comboBox_interval_currentIndexChanged(int index);

    void on_pushButton_pause_clicked();

    void on_pushButton_refresh_clicked();

    void on_pushButton_clear_clicked();

    void on_lineEdit_keyword_textChanged(const QString &arg1);

    void on_comboBox_pnames_currentIndexChanged(const QString &arg1);

    void on_comboBox_pids_currentIndexChanged(const QString &arg1);

    void on_comboBox_keys_currentIndexChanged(const QString &arg1);

private:
    Ui::MainWindow *ui;

private:
    int                m_select;                           /**< -1-noselect, 0-file, 1-dir */
    ilog4x_echo      * m_echo;
    string             m_path;

    bool               m_start;
    bool               m_pause;

    unsigned           m_levels;

    map<string, vector<string> > m_mpids;
    map<string, vector<string> > m_mkeys;
};

#endif // MAINWINDOW_H
